/**
 * @description: 随机生成验证码
 * @return {*}  验证码
 */
const codeArray = [
	0,
	1,
	2,
	3,
	4,
	5,
	6,
	7,
	8,
	9,
	'A',
	'B',
	'C',
	'D',
	'E',
	'F',
	'G',
	'H',
	'I',
	'J',
	'K',
	'L',
	'M',
	'N',
	'O',
	'P',
	'Q',
	'R',
	'S',
	'T',
	'U',
	'V',
	'W',
	'X',
	'Y',
	'Z',
];

const getCode = (len = 4): string => {
	let code = '';
	for (let i = 0; i < len; i++) {
		const index = Math.floor(Math.random() * 35);
		code += codeArray[index];
	}
	return code;
};

export default getCode;
